/// ----------------------------------------------
/// !!! 此文件由工具自动生成，请勿直接修改。 !!!
/// !!! Tabs to Spaces !!!
/// !!! 生成时间：2021-05-10 14:57:34.703
/// ----------------------------------------------

using UnityEngine;
using UnityEditor;
using System.Collections;
using System.IO;
using DLC.Module.DataTable;

namespace DLC.Game.DataTable.ArchiveScriptableObject.Editor
{
    public class ExcelExampleTempExample_1ScriptableObjectAssetPostprocessor : AssetPostprocessor 
    {
        private const string filePath = "Assets/Example/Excel/Example 1.xlsx";
        private const string assetFilePath = "Assets/Example/Excel/ExcelExampleTemp_Example_1.asset";
        private const string sheetName = "ExcelExampleTemp";
    
        static void OnPostprocessAllAssets (string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            foreach (string asset in importedAssets) 
            {
                if (!filePath.Equals (asset))
                    continue;
                
                ExcelExampleTemp data = (ExcelExampleTemp)AssetDatabase.LoadAssetAtPath (assetFilePath, typeof(ExcelExampleTemp));
                if (data == null) {
                    data = ScriptableObject.CreateInstance<ExcelExampleTemp> ();
                    data.SheetName = filePath;
                    data.WorksheetName = sheetName;
                    AssetDatabase.CreateAsset ((ScriptableObject)data, assetFilePath);
                    //data.hideFlags = HideFlags.NotEditable;
                }
            
                //data.DataArray = new ExcelQuery(filePath, sheetName).Deserialize<ExcelExampleTempData>().ToArray();		

                //ScriptableObject obj = AssetDatabase.LoadAssetAtPath (assetFilePath, typeof(ScriptableObject)) as ScriptableObject;
                //EditorUtility.SetDirty (obj);

                ExcelQuery query = new ExcelQuery(filePath, sheetName);
                if (query != null && query.IsValid())
                {
                    data.DataArray = query.Deserialize<ExcelExampleTempData>().ToArray();
                    ScriptableObject obj = AssetDatabase.LoadAssetAtPath (assetFilePath, typeof(ScriptableObject)) as ScriptableObject;
                    EditorUtility.SetDirty (obj);
                }
            }
        }
    }
}
